package com.zhou.gof.group.abstractfactory;

import com.zhou.gof.group.abstractfactory.abstractfactory.AnimalAbstractFactory;
import com.zhou.gof.group.abstractfactory.factory.MammalFactory;
import com.zhou.gof.group.abstractfactory.mammal.Mammal;
import com.zhou.gof.group.abstractfactory.producer.AnimalProducer;

/**
 * @author zhoudong
 * @title: AbstractFactoryTest
 * @projectName user-app
 * @description: TODO
 * @date 2019/5/29 13:56
 */
public class AbstractFactoryTest {
    public static void main(String[] args) {
        // 1、根据动物种类获从动物抽象工厂中取动物种类工厂
        AnimalAbstractFactory animalAbstractFactory = AnimalProducer.getFactory("mammal");
        // 2、根据动物名字从动物种类工厂中获取指定动物
        Mammal mammal = animalAbstractFactory.getMammal("cat");
        // 3、执行方法
        mammal.say("你好"); // 猫说：你好

        animalAbstractFactory.getMammal("dog").say("你好"); // 狗说：你好

        AnimalAbstractFactory factory = AnimalProducer.getFactory("reptile");
        factory.getReptile("lizard").say("你好"); // 蜥蜴说：你好
        factory.getReptile("sanke").say("你好"); // 蛇说：你好
    }
}
